package com.nf.action;

import com.nf.entity.Student;
import com.nf.service.StudentService;
import com.nf.service.StudentServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class CalcAction {

    private StudentService studentService;

    @RequestMapping("/CalcAction")
    public String test(Model model){
        int i = 1+ 1;
        model.addAttribute("iii",i);
        return "test";
    }

    @RequestMapping("/abc")
    public String test2(Model model){
        studentService = new StudentServiceImpl();//当springmvc和Spring完美结合后，此行代码删除，交给ioc容器注入。

        List<Student> studentList = studentService.getStudents();

        model.addAttribute("studentList",studentList);
        return "kkk";
    }
}
